<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    body,
    html {
      width: 100vw;
      height: 100vh;
    }

    .tba {
      margin: 100px auto;
      border-collapse: collapse;
    }

    .tba tr>th {
      width: 80px;
      height: 40px;
      border: 1px solid black;
      background-color: hotpink;
    }

    .tba tbody>tr>td {
      background-color: green;
      border: 1px solid red;
      text-align: center;
      height: 50px;
    }
  </style>
</head>

<body>
  <table class="tba">
    <thead>
      <tr>
        <th>姓名</th>
        <th>科目</th>
        <th>成绩</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>

    </tbody>
  </table>
</body>
<script>
  let datas = [{
    name: "魏鹦洛",
    subject: "java",
    score: 100
  }, {
    name: "弘历",
    subject: "javascript",
    score: 98
  }, {
    name: "傅亨",
    subject: "php",
    score: 97
  }];

  let tbody = document.querySelector("tbody");
  for (let value of datas.values()) {
    let tr = document.createElement("tr");

    for (let key in value) {
      let td = document.createElement("td");
      td.innerHTML = value[key];
      tr.appendChild(td);
    };

    tbody.appendChild(tr);
    // 创建删除单元格
    let td = document.createElement("td");
    td.innerHTML = `<a href="javascript:;">删除</a>`;
    tr.appendChild(td);
  };
  // 制作删除操作
  let as = document.querySelectorAll("a");
  for (let i = 0; i < as.length; i++) {
    as[i].addEventListener("click", (e) => {
      tbody.removeChild(e.currentTarget.parentNode.parentNode);
    });
  };
</script>

</html>